package com.ruoyi.my.controller.courseplan;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.my.domian.courseplan.CoursePlanTeacherVO;
import com.ruoyi.my.service.courseplan.CoursePlanTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/courseplan/teacher")
public class CoursePlanTeacherController extends BaseController {

    @Autowired
    private CoursePlanTeacherService coursePlanTeacherService;

    /**
     * 获取教师列表
     */
    @PreAuthorize("@ss.hasPermi('courseplan:teacher:list')")
    @GetMapping("/list")
    public TableDataInfo list(CoursePlanTeacherVO coursePlanTeacherVO) {
        startPage();
        List<CoursePlanTeacherVO> list = coursePlanTeacherService.selectCoursePlanTeacherList(coursePlanTeacherVO);
        return getDataTable(list);
    }

    /**
     * 从用户表筛选教师到教师表
     */
    @PreAuthorize("@ss.hasPermi('courseplan:teacher:import')")
    @GetMapping("/sysUserToCoursePlanTeacher")
    public AjaxResult sysUserToCoursePlanTeacher() {
        return coursePlanTeacherService.sysUserToCoursePlanTeacher();
    }

    /**
     * 删除教师
     */
    @PreAuthorize("@ss.hasPermi('courseplan:teacher:delete')")
    @DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds) {
        return toAjax(coursePlanTeacherService.deleteCoursePlanTeacherByIds(userIds));
    }

    /**
     * 修改用户
     */
    @PreAuthorize("@ss.hasPermi('courseplan:teacher:update')")
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody CoursePlanTeacherVO coursePlanTeacherVO) {
        return toAjax(coursePlanTeacherService.updateCoursePlanTeacherById(coursePlanTeacherVO));
    }



}
